package com.markerhub.controller;

/**
 * @author jsx on 2023/4/15
 **/

import com.markerhub.common.lang.Result;
import com.markerhub.utils.UploadUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@RestController
public class UploadController {


    /**
     * 返回图片上传后存储的地址
     * @param multipartFile
     * @return
     */
    @PostMapping("upload/image")
    public Result uploadImage(@RequestParam(value = "file") MultipartFile multipartFile){
        if (multipartFile.isEmpty()){
            return Result.fail("文件有误！");
        }
        return Result.succ(UploadUtils.uploadImage(multipartFile));
    }

}
